﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using Yaml.Presentation.Parsing;

namespace Yaml.Tests.Presentation {
    static class Helper {
        static public Reader CreateReader(string content) {
            return CreateReader(content, Encoding.UTF8);
        }

        static public Reader CreateReader(string content, Encoding encoding) {
            List<byte> bytes = new List<byte>();
            bytes.AddRange(encoding.GetPreamble());
            bytes.AddRange(encoding.GetBytes(content));
            return new Reader(new StreamReader(new MemoryStream(bytes.ToArray())));
        }

        static public Scanner CreateScanner(string content) {
            return new Scanner(CreateReader(content));
        }

        static public Scanner CreateScanner(string content, Encoding encoding) {
            return new Scanner(CreateReader(content, encoding));
        }
    }
}
